import type { RouteRecordRaw } from 'vue-router'
import pinia from '@/store'
import useMenuBadgeStore from '@/store/modules/menuBadge'

function Layout() {
  return import('@/layouts/index.vue')
}
const menuBadgeStore = useMenuBadgeStore(pinia)

const routes: RouteRecordRaw = {
  path: '/multilevel_menu_example',
  component: Layout,
  // redirect: '/multilevel_menu_example/page',
  name: 'multilevelMenuExample',
  meta: {
    title: '多级导航',
    icon: 'i-heroicons-solid:menu-alt-3',
    defaultOpened: true,
    alwaysOpened: true,
    breadcrumb: false,
  },
  children: [
    {
      path: 'main_page',
      name: 'main_page',
      component: () => import('@/views/main_page.vue'),
      meta: {
        title: '系统首页',
        breadcrumb: false,
      },
    },
    {
      path: 'monitor_data',
      name: 'monitor_data',
      component: () => import('@/views/monitor_data.vue'),
      meta: {
        title: '监测数据',
        breadcrumb: false,
      },
    },
    {
      path: 'real_time_monitor',
      name: 'real_time_monitor',
      meta: {
        title: '实时值守',
      },
      children: [
        {
          path: 'warn_data',
          name: 'warn_data',
          component: () => import('@/views/warn_data.vue'),
          meta: {
            title: '报警信息',
            badge: () => menuBadgeStore.number1,
            breadcrumb: false,
          },
        },
        {
          path: 'fault_data',
          name: 'fault_data',
          component: () => import('@/views/fault_data.vue'),
          meta: {
            title: '故障信息',
            badge: () => menuBadgeStore.number2,
            breadcrumb: false,
          },
        },
      ],
    },
    {
      path: 'repair_data',
      name: 'repair_data',
      component: () => import('@/views/repair_data.vue'),
      meta: {
        title: '报修数据',
        breadcrumb: false,
      },
    },
    {
      path: 'order_manage',
      name: 'order_manage',
      meta: {
        title: '工单管理',
      },
      children: [
        {
          path: 'order_dispatch',
          name: 'order_dispatch',
          component: () => import('@/views/order_dispatch.vue'),
          meta: {
            title: '工单派遣',
            breadcrumb: false,
          },
        },
        {
          path: 'order_track',
          name: 'order_track',
          // redirect: '/multilevel_menu_example/order_track',
          component: () => import('@/views/order_track.vue'),
          meta: {
            title: '工单追踪',
            breadcrumb: false,
          },
        },
      ],
    },
    {
      path: 'user_manage',
      name: 'user_manage',
      meta: {
        title: '用户管理',
      },
      children: [
        {
          path: 'owner',
          name: 'owner',
          component: () => import('@/views/owner.vue'),
          meta: {
            title: '业主单位',
            breadcrumb: false,
          },
        },
        {
          path: 'electrician',
          name: 'electrician',
          component: () => import('@/views/electrician.vue'),
          meta: {
            title: '电工',
            breadcrumb: false,
          },
        },
        {
          path: 'operate_user',
          name: 'operate_user',
          component: () => import('@/views/operate_user.vue'),
          meta: {
            title: '运维用户',
            breadcrumb: false,
          },
        },
        {
          path: '/order-details/:id',
          name: 'order-details',
          component: () => import('@/views/orderPage.vue'),
          meta: {
            title: '',
            singleMenu: true,
            props: true, // 允许使用 props 接收参数
            breadcrumb: false,
          },
        },
        {
          path: '/report-details/:id',
          name: 'report-details',
          component: () => import('@/views/reportPage.vue'),
          meta: {
            title: '',
            singleMenu: true,
            props: true, // 允许使用 props 接收参数
            breadcrumb: false,
          },
        },
        {
          path: '/monitor-details/:id',
          name: 'monitor-details',
          component: () => import('@/views/monitorPage.vue'),
          meta: {
            title: '',
            singleMenu: true,
            props: true, // 允许使用 props 接收参数
            breadcrumb: false,
          },
        },
      ],
    },
    // {
    //   path: 'test',
    //   name: 'test',
    //   component: () => import('@/views/test.vue'),
    //   meta: {
    //     title: '测试',
    //   },
    // },
    // {
    //   path: 'level2',
    //   name: 'multilevelMenuExample2',
    //   redirect: '/multilevel_menu_example/level2/page',
    //   meta: {
    //     title: '导航2',
    //   },
    //   children: [
    //     {
    //       path: 'page',
    //       name: 'multilevelMenuExample2-1',
    //       component: () => import('@/views/multilevel_menu_example/level2/page.vue'),
    //       meta: {
    //         title: '导航2-1',
    //       },
    //     },
    //     {
    //       path: 'level3',
    //       name: 'multilevelMenuExample2-2',
    //       redirect: '/multilevel_menu_example/level2/level3/page1',
    //       meta: {
    //         title: '导航2-2',
    //       },
    //       children: [
    //         {
    //           path: 'page1',
    //           name: 'multilevelMenuExample2-2-1',
    //           component: () => import('@/views/multilevel_menu_example/level2/level3/page1.vue'),
    //           meta: {
    //             title: '导航2-2-1',
    //           },
    //         },
    //         {
    //           path: 'page2',
    //           name: 'multilevelMenuExample2-2-2',
    //           component: () => import('@/views/multilevel_menu_example/level2/level3/page2.vue'),
    //           meta: {
    //             title: '导航2-2-2',
    //           },
    //         },
    //       ],
    //     },
    //   ],
    // },
  ],
}

export default routes
